import json
import threading
import time

import redis

redis_client = redis.StrictRedis(host='10.100.12.58', port=6379, db=0)


def get_status():
    pubsub = redis_client.pubsub()
    pubsub.subscribe('admin_633_0_5_status')
    print("获取redis的信息")
    # 开始监听消息
    for message in pubsub.listen():
        if message['type'] == 'message':
            receive_data = message['data'].decode('utf-8')
            print('receive_data_status:', receive_data)

def get_simu():
    pubsub = redis_client.pubsub()
    pubsub.subscribe('admin_633_0_5_data')
    print("获取redis的信息")
    # 开始监听消息
    for message in pubsub.listen():
        if message['type'] == 'message':
            receive_data = message['data'].decode('utf-8')
            print('receive_data_simu:', receive_data)

if __name__ == '__main__':
    threading.Thread(target=get_simu).start()
    threading.Thread(target=get_status).start()